var util = require('../../utils/util');
var wxApi = require('../../utils/wxApi');
var wxRequest = require('../../utils/wxRequest');
import config from '../../utils/config';

var lineChart = null;

var app = getApp();
var that;

Page({
  data: {
    user: {}
    ,isload:0
    ,sysset:{}
    ,url:""
  },

  onPullDownRefresh:function(){
  },
  onShow:function(){
      that = this;
      if(!util.judge.isNull(app.globalData.tmp.adurl) && app.globalData.tmp.adurl != "" )
      {
          var url =app.globalData.tmp.adurl;
          that.setData({
              url:url
          });
          app.globalData.tmp.adurl="";
      }
  },
  onLoad: function (options) {
      that = this;
      if(!util.judge.isNull(app.globalData.tmp.adurl) && app.globalData.tmp.adurl != "" )
      {
          
      }else{
          util.showLoading();
          app.getUserInfo(false)
          .then(res => {

            if(!util.judge.isObject(res)){
                that.setData({
                    user:res
                })
            }
             
              var url = config.url_get_self_set;
              var params = {
                  name:"dhkb_url"
              }
              return wxRequest.postRequest(url, params);
          })
          .then(res=>{
              console.log(res);
              that.setData({
                  url:res
              });
          })
          .catch(res => {
              util.alert_catch(res);
          })
          .finally(function (res) {
              util.hideLoading();
          });
      }
  },
  onShareAppMessage: function (options) {
      console.log(options.webViewUrl)
      return app.getShare();
  }

  ,showPage(url){
        that.setData({
            url : url
        });
    }

})
